Learn R Programming

Compositional (version 1.5)

Cross validation for the ridge regression: Cross validation for the ridge regression

Description

Cross validation for the ridge regression is performed using the TT estimate of bias (Tibshirani and Tibshirani, 2009). There is an option for the GCV criterion which is automatic.

Usage

ridge.tune(y, x, M = 10, lambda = seq(0, 2, by = 0.1), mat = NULL, ncores = 1, graph = FALSE)

Arguments

y
A numeric vector containing the values of the target variable. If the values are proportions or percentages, i.e. strictly within 0 and 1 they are mapped into R using the logit transformation.
x
A numeric matrix containing the variables. Rows are samples and columns are features.
M
The number of folds. Set to 10 by default.
lambda
A vector with the a grid of values of $\lambda$ to be used.
mat
You can specify your own folds by giving a mat, where each column is a fold. Each column contains indices of the observations. You can also leave it NULL and it will create folds.
ncores
The number of cores to use. If it is more than 1 parallel computing is performed.
graph
If graph is set to TRUE the performances for each fold as a function of the $\lambda$ values will appear.

Value

A list including:
msp
The performance of the ridge regression for every fold.
mspe
The values of the mean prediction error for each value of $\lambda$.
lambda
The value of $\lambda$ which corresponds to the minimum MSPE.
performance
The minimum bias corrected MSPE along with the estimate of bias.
runtime
The time required by the cross-validation procedure.

Details

A k-fold cross validation is performed and the estimated performance is bias corrected as suggested by Tibshirani and Tibshirani (2009). This function is used by alfaridge.tune.

References

Hoerl A.E. and R.W. Kennard (1970). Ridge regression: Biased estimation for nonorthogonal problems. Technometrics, 12(1):55-67.

Brown P. J. (1994). Measurement, Regression and Calibration. Oxford Science Publications.

Tibshirani R.J., and Tibshirani R. (2009). A bias correction for the minimum error rate in cross-validation. The Annals of Applied Statistics 3(2): 822-829.

See Also

ridge.reg, alfaridge.tune

Examples

Run this code
y <- iris[, 1]
x <- iris[, 2:4]
ridge.tune( y, x, M = 10, lambda = seq(0, 2, by = 0.1), graph = TRUE )

Run the code above in your browser using DataLab